<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="gmms" uri="/gmms-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<c:choose>
<c:when test="${loadData==null}">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>菜单管理</title>
<jsp:include page="../head.jsp" />
<script language="javascript">

function del(keyId){
  xbox.confirm("您正在执行删除操作,确认吗?", function (result) {
      if (result) {
    	  $.ajax({
				url			:"<%=path%>/menu/menuAjax_delete_msgAction.action",
				type 		: "POST",
				dataType 	: "json",
				data		: {
					"menuId" : keyId
				},
				success 	: function(data) {
					j_loadData($("#currentPage").val());
				},
				error		:function(){
					xbox.alert("数据正在提交，请稍候，或检查您的网络环境,确保其连接正常！");
				}
			});
      }
  }, {
      title: '系统提示',
      value: '确定'
  });
   
}

function toAdd(){
	j_goUrl("<%=path%>/menu/menu_toAdd_addAction.action",1);
}

function toReset(){
	xbox.load("loading");
  	$.ajax({
		url			:"<%=path%>/menu/menuAjax_resetOrder_msgAction.action",
		type 		: "POST",
		dataType 	: "json",
		success 	: function(data) {
			j_tip("序号重置成功！", "succes");
		},
		error		:function(){
			xbox.alert("数据正在提交，请稍候，或检查您的网络环境,确保其连接正常！");
		}
	});
}

function toSort(){
	openModelWindow("菜单排序","<%=path %>/menu/menu_loadMenu_sortAction.action?parentMenuId=0",480);
}

function toEdit(keyId){
	j_goUrl("<%=path%>/menu/menu_toEdit_editAction.action?menuId="+keyId,$("#currentPage").val());
}

function toEditName(keyId){
	j_goUrl("<%=path%>/menu/menu_toEdit_editAction.action?menuId="+keyId,$("#currentPage").val());
}

</script>
</head>
<body>


<div class="info_right_main">
<form action="<%=path%>/menu/menu_queryList_listAction.action" method="post" id="refreshForm" name="refreshForm">
	<input type="hidden" id="currentPage" name="currentPage" value="${currentPage}"/>
    <c:if test='${fn:contains(authorityCode,",0001,") or fn:contains(authorityCode,",0005,")}'>
	        <div class="info_right_tab">
	        	<ul style="margin-top:30px;">
	            	<li style="width:70px;">菜单名称：</li>
	                <li><input type="text" id="menuName4Search" name="menuName" value="${menuName}" class="info_right_input" maxlength="15" /></li>
	                <li style="width:140px;"><input class="btn" onclick="j_search(1)" id="btnSearch" type="button" value="查询" /> 
	                <input class="btn" onclick="j_search(1,true);" type="button" value="重置" /></li>
	            </ul>
		</div>
	</c:if>
</form>
<div class="info_right_ctrl">
	<c:if test="${DEVELOP_MODEL}">
		<c:if test='${fn:contains(authorityCode,",0001,") or fn:contains(authorityCode,",0002,")}'>
			<input class="btn" onclick="toAdd();" type="button" value="添加菜单" />
		</c:if>
		<c:if test='${fn:contains(authorityCode,",0001,")}'>
			<input class="btn" onclick="toReset();" type="button" value="菜单序列化" />
		</c:if>
	</c:if>
	<c:if test='${sessionScope.sessionUser.userId eq 1}'>
    	<input class="btn" type="button" onclick="toSort();" value="菜单排序" />
    </c:if>
    <input class="btn" type="button" onclick="j_search(1,true);" value="更新列表" />
    <span style="font-size:13px;padding-top:15px;float:right;padding-right:30px;cursor: pointer;" onclick="operationManual(${currentMenuId})">
    	<img src="<%=path %>/images/help.png" title="帮助" />帮助
    </span>
</div>
        
        
<div class="info_right_main">
	<div id="gridHead">
		<table width="100%" border="0" cellspacing="0" cellpadding="0" style="TABLE-LAYOUT:fixed;">
		 	<tr height="35">
	         <td width="5%" align="center"><strong>序号</strong></td>
	         <td width="15%" align="center"><strong>菜单名称</strong></td>
	         <td width="10%" align="center"><strong>菜单ID</strong></td>
	         <td width="10%" align="center"><strong>菜单级别</strong></td>
	         <td width="10%" align="center"><strong>菜单URL</strong></td>
	         <td width="15%" align="center"><strong>记录创建时间</strong></td>
	         <td width="25%" align="center"><strong>操作</strong></td>
	       </tr>
		</table>
	</div>
	<div style="overflow:auto;display:none;" id="divGrid">
	</div>
	<table border="0" cellspacing="0" cellpadding="0" width="100%" id="tablePager"></table>
</div>
  
</div>

</body>
</html>
</c:when>
<c:otherwise>
<table id="gridTable" width="100%" border="0" cellspacing="0" cellpadding="0">
	       <c:forEach items="${list}" var="menu" varStatus="status">
				<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#f1f1f1';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="30" >
					<td>${status.index+1}</td>
					<td>
					<c:if test="${menu.parentMenuId eq 0}">
				    	<span style="color:#FF0000"><b>${menu.menuName}</b></span>
				    </c:if>
				    <c:if test="${(menu.parentMenuId ne 0)}">
				    	<span style="color:#FFA500">${menu.menuName}</span>
				    </c:if>
				    <%--
				    <c:if test="${(menu.backupData mod 100 ne 0) and (menu.backupData mod 10 eq 0) and (menu.backupData gt 100)}">
				    	<span style="color:#7B68EE">${menu.menuName}</span>
				    </c:if>
				    
				    <c:if test="${(menu.backupData mod 10 ne 0) and (menu.backupData gt 100)}">
				    	<span style="color:#32CD32">${menu.menuName}</span>
				    </c:if>--%>
				    </td>
					<td>${menu.menuId}</td>
					<td><c:if test="${menu.publicMenu eq 1}">公共菜单</c:if><c:if test="${menu.publicMenu ne 1}">普通菜单</c:if></td>
					<td>${menu.menuUrl}</td>
					<td><fmt:formatDate value="${menu.createTime}" pattern="yyyy-MM-dd HH:mm"/></td>
					<td>
						<c:if test='${fn:contains(authorityCode,",0001,") or fn:contains(authorityCode,",0003,")}'>
							<c:if test="${DEVELOP_MODEL}">
								<span style="width:140px;"><input class="btn" onclick="toEdit(${menu.menuId});" type="button" value="编辑" /></span>
							</c:if>
							<c:if test="${DEVELOP_MODEL eq false}">
								<span style="width:140px;"><input class="btn" onclick="toEditName(${menu.menuId});" type="button" value="编辑" /></span>
							</c:if>
						</c:if>
						 <c:if test='${fn:contains(authorityCode,",0001,") or fn:contains(authorityCode,",0004,")}'>
						 	<input class="btn" onclick="del(${menu.menuId});" type="button" value="删除" />
						 </c:if>
					</td>
				</tr>
			</c:forEach>
			<tr align="right" bgcolor="#f1f1f1">
				<td height="30" colspan="7" align="right">
				 <!-- 分页 -->
 				<gmms:pages currentPage="%{currentPage}" totalPage="%{totalPage}" />
				</td>
			</tr>
     </table>
</c:otherwise>
</c:choose>